<template>
  <div>       
        <div v-if="show" class="loading">加载中<van-loading /></div>
         <indexItemContentView v-else :dataList="dataList"></indexItemContentView>
  </div>
</template>

<script>
import indexItemContentView from "./indexItemContentView.vue"; 
import {getIndexDataAPI} from "../../assets/api"
export default {
    data(){
        return{
            dataList:[],
            show:true,
        }
    },
    methods:{
        async getIndexData(t,i){
            console.log(t,i);
            console.log(this.$route);
            let url = getIndexDataAPI(t,i)
            let {data} = await this.$http(url)
            console.log("请求到的数据=>",data); 
            this.dataList = data.data.data
            if(this.dataList != ''){
                this.show = false
            }else{
                this.show = true
            }
            
        }
    },
    created(){
        this.getIndexData(this.$route.params.type,this.$route.params.id)
        
    },
    beforeRouteUpdate(to,from,next){
        this.getIndexData(to.params.type,to.params.id)  
        next()
    },
    components:{
        indexItemContentView,
    }
}
</script>

<style lang="scss" scoped>
.loading{
    display: flex;
    justify-content: center;
}
</style>